package com.ruoyi.passenger.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.passenger.domain.TbPassengerDriverRole;
import com.ruoyi.passenger.service.ITbPassengerDriverRoleService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 司机角色关联Controller
 * 
 * @author ruoyi
 * @date 2025-08-21
 */
@RestController
@RequestMapping("/guanlian")
public class TbPassengerDriverRoleController extends BaseController
{
    @Autowired
    private ITbPassengerDriverRoleService tbPassengerDriverRoleService;

    /**
     * 查询司机角色关联列表
     */
    @RequiresPermissions("passenger:guanlian:list")
    @GetMapping("/list")
    public TableDataInfo list(TbPassengerDriverRole tbPassengerDriverRole)
    {
        startPage();
        List<TbPassengerDriverRole> list = tbPassengerDriverRoleService.selectTbPassengerDriverRoleList(tbPassengerDriverRole);
        return getDataTable(list);
    }

    /**
     * 导出司机角色关联列表
     */
    @RequiresPermissions("passenger:guanlian:export")
    @Log(title = "司机角色关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPassengerDriverRole tbPassengerDriverRole)
    {
        List<TbPassengerDriverRole> list = tbPassengerDriverRoleService.selectTbPassengerDriverRoleList(tbPassengerDriverRole);
        ExcelUtil<TbPassengerDriverRole> util = new ExcelUtil<TbPassengerDriverRole>(TbPassengerDriverRole.class);
        util.exportExcel(response, list, "司机角色关联数据");
    }

    /**
     * 获取司机角色关联详细信息
     */
    @RequiresPermissions("passenger:guanlian:query")
    @GetMapping(value = "/{driverRoleId}")
    public AjaxResult getInfo(@PathVariable("driverRoleId") Long driverRoleId)
    {
        return success(tbPassengerDriverRoleService.selectTbPassengerDriverRoleByDriverRoleId(driverRoleId));
    }

    /**
     * 新增司机角色关联
     */
    @RequiresPermissions("passenger:guanlian:add")
    @Log(title = "司机角色关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPassengerDriverRole tbPassengerDriverRole)
    {
        return toAjax(tbPassengerDriverRoleService.insertTbPassengerDriverRole(tbPassengerDriverRole));
    }

    /**
     * 修改司机角色关联
     */
    @RequiresPermissions("passenger:guanlian:edit")
    @Log(title = "司机角色关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPassengerDriverRole tbPassengerDriverRole)
    {
        return toAjax(tbPassengerDriverRoleService.updateTbPassengerDriverRole(tbPassengerDriverRole));
    }

    /**
     * 删除司机角色关联
     */
    @RequiresPermissions("passenger:guanlian:remove")
    @Log(title = "司机角色关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverRoleIds}")
    public AjaxResult remove(@PathVariable Long[] driverRoleIds)
    {
        return toAjax(tbPassengerDriverRoleService.deleteTbPassengerDriverRoleByDriverRoleIds(driverRoleIds));
    }
}
